
using System.ComponentModel.DataAnnotations;

namespace AdminSG3L.Domain.Entities;

/// <summary>
/// 管理文件实体
/// </summary>
public class AdminFile : EntityBase
{
    /// <summary>
    /// 文件名，必填
    /// </summary>
    public string FileName { get; private set; }
    /// <summary>
    /// 文件路径，可选
    /// </summary>
    public string? FilePath { get; private set; }
    /// <summary>
    /// 文件大小，可选
    /// </summary>
    public long FileSize { get; private set; }
    /// <summary>
    /// 文件类型，可选
    /// </summary>
    public string? FileType { get; private set; }

    /// <summary>
    /// 上传用户Id
    /// </summary>
    public Guid UserId { get; private set; }
    /// <summary>
    /// 上传用户
    /// </summary>
    public AppUser? User { get; private set; }

    /// <summary>
    /// 私有构造函数，仅限工厂方法调用
    /// </summary>
    private AdminFile(string fileName, string? filePath, long fileSize, string? fileType, Guid userId, AppUser? user, string? description)
    {
        FileName = fileName;
        FilePath = filePath;
        FileSize = fileSize;
        FileType = fileType;
        UserId = userId;
        User = user;
        Description = description;
    }

    /// <summary>
    /// 创建AdminFile对象的工厂方法
    /// </summary>
    /// <param name="fileName">文件名</param>
    /// <param name="filePath">文件路径</param>
    /// <param name="fileSize">文件大小</param>
    /// <param name="fileType">文件类型</param>
    /// <param name="description">描述</param>
    /// <returns>AdminFile对象</returns>
    public static AdminFile Create(string fileName, string? filePath = null, long fileSize = 0, string? fileType = null, Guid userId = default, AppUser? user = null, string? description = null)
    {
        return new AdminFile(fileName, filePath, fileSize, fileType, userId, user, description);
    }
}
